home *** CD-ROM | disk | FTP | other *** search
/ .net 2002 March / DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin / pc / PC Software / Coldfusion / coldfusion-60-win-en.exe / ls007008_comp.jpg < prev    next >
Encoding:
Text File  |  1999-10-22  |  7.5 KB  |  213 lines

  1. TIONS SET FORTH IN THE CORRESPONDING EULA.
  2. *
  3. **
  4.  --->
  5.  
  6. <!--- 
  7. Flash is only sending one parameter to this page, so the variable
  8. is set to the first parameter in the params array.  Flash can also
  9. pass named params - in which case this page could refer to them as; 
  10.     FLASH.paramName
  11. In this example;
  12.     FLASH.yourName
  13.  --->        
  14.  
  15. <cfset yourName = flash.params[1]>
  16.  
  17. <!--- Do something with the information that came from Flash... --->
  18. <cfset aGreeting = "Hello, " & yourName & "!">
  19.  
  20. <!--- And send it back in the FLASH.result variable --->
  21. <cfset flash.result = aGreeting>    <!--- 
  22. **
  23. * CFMX Example Applications 
  24. *
  25. * Copyright (c) 2002 Macromedia.  All Rights Reserved.
  26. *
  27. * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
  28. * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
  29. *
  30. **
  31.  --->
  32.  
  33. <cfmodule template="../tags/layout.cfm" pageName="Flash Example 2 - Hello To You">
  34.  
  35.  
  36. <p>
  37. The previous example had information (a simple greeting) passed from the server to the client.  Nearly all applications, however, require information to pass both ways - from client to server and back.  In this example, a user enters a string in the Flash application.  Flash then passes that string to the server to be used in an action there.
  38. </p>
  39.  
  40. <br>
  41.  
  42. <table border="1">
  43. <tr>
  44.     <td>
  45.     
  46. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="550" height="200">
  47. <cfoutput>
  48.   <param name="flashvars" value="gatewayUrl=http://#cgi.http_host#/flashservices/gateway">
  49. </cfoutput>
  50.   <param name="movie" value="flash2.swf">
  51.   <param name="quality" value="high">
  52.   <embed src="flash2.swf" 
  53.   <cfoutput>
  54.   flashvars="gatewayUrl=http://#cgi.http_host#/flashservices/gateway"
  55.   </cfoutput>
  56.   quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="550" height="200">
  57.   </embed>
  58. </object>
  59.  
  60. </td>
  61. </tr>
  62. </table>
  63.  
  64.  
  65. <br><br><br>
  66.  
  67.  
  68. </cfmodule>
  69. <!--- 
  70. **
  71. * CF MX Demos 
  72. *
  73. * Copyright (c) 2002 Macromedia.  All Rights Reserved.
  74. * DO NOT REDISTRIBUTE THIS SOFTWARE IN ANY WAY WITHOUT THE EXPRESSED
  75. * WRITTEN PERMISSION OF MACROMEDIA.
  76. --->
  77.  
  78. <cfmodule template="../tags/layout.cfm" pageName="Flash Example 2 - Hello To You">
  79.  
  80.     <cfset variables.files = "index.cfm,flash2dataprovider.cfm">
  81.  
  82.     <cfinclude template="../tags/showsource.cfm">
  83.  
  84. </cfmodule>
  85. <!--- 
  86. **
  87. * CFMX Example Applications 
  88. *
  89. * Copyright (c) 2002 Macromedia.  All Rights Reserved.
  90. *
  91. * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
  92. * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
  93. *
  94. **
  95.  --->
  96.  
  97. <cfmodule template="../tags/bts_layout.cfm" exampleName="Flash Example 3 - News Ticker"
  98.     source="index.cfm,newsdata.cfm,flash3.cfc"
  99.     keyTags="">
  100.  
  101.     <p>
  102. The first two examples used CFML templates to provide server-side logic to the Flash application.  In this and subsequent examples, ColdFusion Components (CFCs) are used.  The page approach is somewhat limited in that it uses the special FLASH variable scope (FLASH.params, FLASH.result, etc.).  This means that the page cannot be used for any other purpose.  When logic is implemented in a CFC, however, it can power a Flash application as well as other consumers, such as cfml pages or web services, without the need to re-write any code.  It also brings all of the other benefits of components (team collaboration, code reuse, etc.) to Flash/ColdFusion projects.  To view the component's self-documenting page, <a href="flash3.cfc" target="_blank">click here</a>.
  103. <br><br>
  104. The Actionscript remains very similar when using CFCs over CFML pages.  The major difference is that gatewayConnection.getService function points to the specific component instead of the directory (as was the case in the CFML page based examples) and the CFCs function is invoked instead of the CFML page.  For example, a component <font face="Courier New">cfdocs\exampleapps\flash3\flash3.cfc</font> could be invoked as follows;<br><br>
  105.      <font face="Courier New">serverCall = gatewayConnection.getService("cfdocs.exampleapps.Flash3.Flash3", new getHeadlines());
  106. </font>
  107.     </p>
  108.     
  109.     
  110.  
  111. </cfmodule><!--- 
  112. **
  113. * CFMX Example Applications 
  114. *
  115. * Copyright (c) 2002 Macromedia.  All Rights Reserved.
  116. *
  117. * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE
  118. * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA.
  119. *
  120. **
  121. Author:
  122. S. Holmes / sholmes@breckcomm.com
  123. Breckenridge Communications - www.breckcomm.com
  124. 3/6/2002
  125.  
  126. rcamden:
  127. Updated getAllnews method to use xml newsfeed.
  128. --->
  129.  
  130. <cfcomponent hint="This is the news object component which passes a query recordset to Flash.">
  131.  
  132.     <!--- 
  133.         This is a simple component function which requires no input parameters,
  134.         and returns all the news currently found in the database.     
  135.     --->
  136.     <cffunction name="getAllNews" access="remote" returnType="query" hint="This function returns the latest news from the db in a query object.">
  137.  
  138.         <cflock scope="application" type="readOnly" timeout=3>
  139.         <cfif not isDefined("application.xmlData")>
  140.             <cfset variables.init = 1>
  141.         </cfif>
  142.         </cflock>
  143.         
  144.         <cfif isDefined("variables.init")>
  145.         
  146.             <cftry>
  147.                 <cflock scope="application" type="exclusive" timeout=3>
  148.                 <cfset xmlURL = "http://www.macromedia.com/desdev/resources/macromedia_resources.xml">
  149.                 
  150.                 <cfhttp url="#xmlURL#">
  151.                 <cfset packet = XMLParse(cfhttp.filecontent)>
  152.     
  153.                 <cfset data = packet.macromedia_resources.resource>
  154.                 <cfset newsQry = queryNew("newsID,headline,story,url")>
  155.                 <cfloop index="x" from=1 to="#arrayLen(data)#">
  156.                     <cfset queryAddRow(newsQry)>
  157.                     <cfset querySetCell(newsQry,"newsID",newsQry.recordCount)>
  158.                     <cfset querySetCell(newsQry,"headline",data[x].title.xmlText)>
  159.                     <cfset querySetCell(newsQry,"url",data[x].url.xmlText)>
  160.                     <cfset story = "A #lCase(data[x].xmlAttributes.type)# by #data[x].author.xmlText# about ">
  161.                     <cfloop index="y" from=1 to="#arrayLen(data[x].product)#">
  162.                         <cfset story = story & "#replace(data[x].product[y].xmlAttributes.name,"_"," ","ALL")#">
  163.                         <cfif y lt arrayLen(data[x].product)>
  164.                             <cfset story = story & ",">
  165.                             <cfif y is arraylen(data[x].product)-1>
  166.                                 <cfset story = story & " and ">
  167.                             <cfelse>
  168.                                 <cfset story = story & " ">
  169.                             </cfif>
  170.                         <cfelse>
  171.                             <cfset story = story & ".">
  172.                         </cfif>
  173.                     </cfloop>
  174.                     <cfset story = story & "
  175.     
  176. #data[x].url.xmlText#">
  177.                     
  178.                     <cfset querySetCell(newsQry,"story",story)>                
  179.                 </cfloop>
  180.                 
  181.                 <cfif newsQry.recordCount>
  182.                     <cfset application.xmlData = newsQry>
  183.                 <cfelse>
  184.                     <cfset useDefault = 1>
  185.                 </cfif>
  186.                 </cflock>
  187.                 
  188.                 <cfcatch>
  189.                     <cfset useDefault = 1>
  190.                 </cfcatch>
  191.                 
  192.             </cftry>
  193.             
  194.             <!--- if useDefault, use the old file, newsdata --->
  195.             <cfif isDefined("useDefault") and useDefault>
  196.                 <cfinclude template="newsdata.cfm">
  197.                 <cflock scope="application" type="exclusive" timeout=3>
  198.                     <cfset application.xmlData = virtualNewsTable>
  199.                 </cflock>
  200.             </cfif>
  201.             
  202.         </cfif>
  203.             
  204.         <!--- 
  205.             Return the query result (newsQry is the name specified in 
  206.             the CFQUERY tag above)
  207.         --->
  208.         <cfreturn application.xmlData>
  209.     
  210.     </cffunction>
  211.     
  212. </cfcomponent>
  213. –œ‡°±·>˛ˇ    ˛ˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇ